package openadmin.model.control;

/**
 * <desc>class that stores the basic information of entity</desc>
 * <responsibility>Represents entity</responsibility>
 * <coperation>Interface Base - Class Access</coperation>
 * @version  0.1
 * Created 10-05-2008
 * Modifier 15-04-2009 
 * Author Alfred Oliver
*/

import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;

import openadmin.dao.Base;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

@Entity
@Table(name = "entityadm", schema = "control", uniqueConstraints = {@UniqueConstraint(columnNames = "entityCode"), @UniqueConstraint(columnNames="description")})
public class EntityAdm implements Base, java.io.Serializable {

	/** attribute that contains the identifier*/
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)	
	private Integer id;
	
	/** attribute that contains the entityCode*/
	@NotNull
	private Integer entityCode;		

	/** attribute that contains the description*/
	@NotNull
	@Length(min = 4, max = 25)
	private String description;
	
	/** Transient attribute that means that the system should make a log on any JPA operation of this class*/
	@Transient 
	private boolean debuglog = true;
	
	/** Transient attribute that means that the system should make a historic on any JPA operation of this class*/
	@Transient
	boolean historiclog = false;
	
	/** attribute that contains the access*/
	//@OneToMany(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER, mappedBy = "entityAdm")
	//private Set<Access> access;
		
	/**
	 * Constructor of the class ActionClass.
	 * without parameters
	 */
	public EntityAdm(){
		
	}

	/**
	 * Constructor of the class Entity.
	 * @param pDescription, is the description, (unique value), of the Entity
	 */
	public EntityAdm(String pDescription){
		this.description = pDescription;
	}
	
	/** Getters and setters*/
	public Integer getId() {
		return this.id;
	}
	
	public void setId(int pId) {
		this.id = pId;
	}
	
	public Integer getEntityCode() {
		return entityCode;
	}

	public void setEntityCode(Integer pEntityCode) {
		this.entityCode = pEntityCode;
	}
	
	public String getDescription() {
		
		return this.description;
	}

	public void setDescription(String pDescription) {
		
		this.description = pDescription;
		
	}
	
	public boolean getDebugLog() {
		
		return debuglog;
	}
	
	public void setDebugLog(boolean pDebuglog) {
		
		debuglog = pDebuglog;
	
	}
	
	public boolean getHistoricLog() {
		return historiclog;
	}

	public void setHistoricLog(boolean historiclog) {
		this.historiclog = historiclog;
	}
	
	@Override
	public String toString(){
	      
		return entityCode + " " + description;
	
	}
		
}
